import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-09-14
 * Time: 14:24
 */
public class Main1 {
    public static void main1(String[] args) {
        ArrayList<Integer> list = new ArrayList<>(10);
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        list.add(6);

        System.out.println(list);
//        System.out.println(list.contains(2));
        List<Integer> ret = list.subList(0, 2);//修改ret,也会修改原来的内容
        System.out.println(ret);

        System.out.println(list.size());

        list.remove(Integer.valueOf(6));
        System.out.println(list);

    }

    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>(10);
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        list.add(6);

        Iterator<Integer> it = list.iterator();


        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }

    }
}
